// 2025/2/24
// https://www.lanqiao.cn/problems/20030/learning/?page=1&first_category_id=1
// 铠甲合体
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int find(map<long long, int, greater<long long>>& As, long long B)
{
    auto it = As.begin();
    int count = 0, cur = 0;
    while (it != As.end() && B > 0)
    {
        cur = min((long long)it->second, B / it->first);
        B -= cur * it->first;
        count += cur;
        ++it;
    }
    if (B == 0)
        return count;
    else
        return -1;
}

int main()
{
    // 请在此输入您的代码
    int N, M; cin >> N >> M;
    map<long long, int, greater<long long>> As;
    for (int i = 0; i < N; i++)
    {
        long long tmp; cin >> tmp;
        As[tmp]++;
    }

    long long B = 0;
    for (int j = 0; j < M; j++)
    {
        cin >> B;
        cout << find(As, B) << " ";
    }

    return 0;
}